package com.xmb.common.service.impl;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by lyndon on 2019/3/27.
 */
public class GetPayOrderStrategyHolder {

    private static GetPayOrderStrategyHolder singleton = null;

    private Map<String, GetPayOrderStrategy> strategyMap = null;

    private GetPayOrderStrategyHolder() {
        this.strategyMap = new HashMap<>();
    }

    public static synchronized GetPayOrderStrategyHolder getSingleton() {
        if (singleton == null) {
            singleton = new GetPayOrderStrategyHolder();
        }
        return singleton;
    }

    public void registerStrategy(GetPayOrderStrategy strategy) {
        this.strategyMap.put(strategy.getType(), strategy);
    }

    public GetPayOrderStrategy getStrategy(String type) {
        return this.strategyMap.get(type);
    }
}
